$('.paixu a').click(function () {
    $(this)
        .addClass('on')
        .siblings('a')
        .removeClass('on')
        .siblings('div')
        .eq($(this).index())
        .addClass('on')
        .siblings('div')
        .removeClass('on')
})
$('.daikan-a').click(function () {
    $('.daikan-a i').show()
    $('.fangyuan-a i').hide()
    $('.chengjiao-a i').hide()
})
$('.fangyuan-a').click(function () {
    $('.daikan-a i').hide()
    $('.fangyuan-a i').show()
    $('.chengjiao-a i').hide()
})
$('.chengjiao-a').click(function () {
    $('.daikan-a i').hide()
    $('.fangyuan-a i').hide()
    $('.chengjiao-a i').show()
})
$('.moren-a').click(function () {
    $('.daikan-a i').hide()
    $('.fangyuan-a i').hide()
    $('.chengjiao-a i').hide()
})
let oRow = document.querySelectorAll('.list')
let allList = []
let arr = []
ajax({
    scriptCharset: 'utf-8',
    url: '../../php/anphp/middleman.php',
    type: 'get',
    data: {
        pagenum: 1,
        pagesize: 5
    },
    success(res) {
        arr = JSON.parse(res)
        // 判断有没有数据
        if (arr.length === 0) {
            oDataText.innerHTML = '没有数据'
            // 进入条件下面的循环也就不用执行了
            return
        }

        function sortBy(props) {
            return function (a, b) {
                return a[props] - b[props];
            }
        }
        // 分类排序
        allList.push([...arr])
        let a1 = [...arr.sort(sortBy('ershoufang'))]
        let a2 = [...arr.sort(sortBy('chengjiao'))]
        let a3 = [...arr.sort(sortBy('daikan'))]
        allList.push(a3,a1,a2)
        oRow.forEach((elt,index) => {
            let str = ''
            allList[index].forEach(ele => {
                str += `<div class="list-con">
                    <div class="list-cons">
                    <div class="list-cosl">
                        <img src="${ele.img}" alt="">
                        <ul>
                            <li>${ele.username}</li>
                            <li>服务区域: <span>罗湖</span>&nbsp;<span>笋岗</span></li>
                            <li>二&nbsp;&nbsp;手&nbsp;&nbsp;房: <span>${ele.ershoufang}</span>套&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;租&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;房:<span>24</span>套</li>
                            <li>历史成交: <span>${ele.chengjiao}</span>套 &nbsp;&nbsp;&nbsp;&nbsp;历史带看:<span>${ele.daikan}</span>套</li>
                        </ul>
                    </div>
                    <div class="list-conr">
                        <dl>
                            <dt>${ele.iphone}</dt>
                            <dd>联系电话</dd>
                        </dl>
                    </div>
                </div>
                </div>`

                
            })
            elt.innerHTML = str
        });
    }
})